package com.starry.module.system.core.dict.mapper;

import com.starry.core.common.domain.vo.PageVo;
import com.starry.db.core.mapper.BaseMapperX;
import com.starry.db.core.query.LambdaQueryWrapperX;
import com.starry.module.system.api.dict.domain.qo.SysDictionaryPageQo;
import com.starry.module.system.core.dict.entity.SysDictionary;
import org.apache.ibatis.annotations.Mapper;

/**
 * 系统字典-数据库服务层
 *
 * @author xiaoke
 */
@Mapper
public interface SysDictionaryMapper extends BaseMapperX<SysDictionary> {

    /**
     * 分页查询
     *
     * @param pageQo 分页参数
     * @return PageVo<SysDictionary>
     */
    default PageVo<SysDictionary> selectPage(SysDictionaryPageQo pageQo) {
        return selectPage(pageQo, new LambdaQueryWrapperX<SysDictionary>()
                .likeIfPresent(SysDictionary::getCode, pageQo.getCode())
                .likeIfPresent(SysDictionary::getName, pageQo.getName())
                .eqIfPresent(SysDictionary::getStatus, pageQo.getStatus())
                .orderByDesc(SysDictionary::getId)
        );
    }
}

